﻿<extend name="Public:base" />
<block name="title"><title>我喜欢的项目</title></block>
<block name="header_styles">
    <style type="text/css">
        .main-wrapper .container {
            background-color: #ffffff;
        }
        .form-group {
            margin-bottom: 0px;
        }
    </style>
</block>
<block name="main">
    <div class="tabs-wrapper">
        <div class="section">
            <div class="section-title">
                我喜欢的项目 <span class="help-info">这里你可以查看你喜欢的各个项目，并且可以取消关注不喜欢的项目。</span>
            </div>
            <div class="section-content">
                <div class="favorite-list">
                    <volist name="fav" id="vo">
                        <div class="item" data-fid="{$vo.fid}" data-tid="{$vo.tid}">
                            <a href="javascript:void(0);" class="button-remove"><i class="fa fa-close"></i></a>
                            <div class="row">
                                <div class="col-xs-3">
                                    <img src="__APP__/{$vo.logo|toLogo}" alt="" width="240" class="pull-left" />
                                </div>
                                <div class="col-xs-9">
                                    <div>
                                        <a href="{$vo.id|genJobURL}">
                                            <span class="project-name">{$vo.tname}</span> &nbsp; <span class="project-owner">{$vo.creater}</span>
                                        </a>
                                    </div>
                                    <div class="project-counter">
                                        <span>总招募数: {$vo.jobs}人</span>&nbsp;&nbsp;&nbsp;<span>剩余席位: {$vo['jobs']-$vo['jobsok']}人</span>
                                    </div>
                                    <div class="project-desc">
                                        {$vo.abstract}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </volist>
                    <div class="pagination page-style2">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="footer_scripts">

    <div style="display: none;">
        <div id="removeConfirm" class="box" style="width:450px;">
            <div class="box-title">
                <a href="javascript:void(0)" class="pull-right" style="color: #ffffff;" onclick="$.fancybox.close();"><i class="fa fa-times"></i></a>
                项目删除
            </div>
            <div class="box-content">
                <p class="text-center">
                    <br />
                    确定要删除您喜欢的项目？
                    <br />
                    <br />
                    （您还可以在项目库中找到它）
                    <br /><br />
                </p>
                <div class="box-buttons">
                    <button class="btn btn-success sure">确定</button>
                    <button class="btn btn-success cancel">取消</button>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        require(["jquery"], function () {
            $(function () {
                $(".favorite-list .item .button-remove").click(function () {
                    var button = $(this);
                    $.fancybox.open("#removeConfirm", { autoSize: true, padding: 0, closeBtn: false });
                    $("#removeConfirm button.sure").off("click").click(function () {
                        $.fancybox.close();
                        var itemElement = button.closest(".item");
                        var itemId = itemElement.data("fid"); //favorite ID
                        var tid = itemElement.data("tid");//项目id
                        var url = "{:U('/Project/del_fav/')}";
                        $.post(url, { 'fid': itemId, 'tid': tid }, function (data) {
                            var vdata = eval(data);
                            if (vdata.success == 1) {
                                alert(vdata.msg);
                                itemElement.remove();
                            }
                            else {
                                alert(vdata.msg);
                                return false;
                            }
                        }, 'json');
                    });
                });

                $("#removeConfirm button.cancel").off("click").click(function () { $.fancybox.close(); });
            });
        });

        
    </script>
</block>
